import json

# str1 = {"a": 1, "b": "坚果"}

# # 把json字符串转化成dict
# s = json.loads(str1)
# print(s)
# print(type(s))

# # 把dict转化成json字符串，默认内容是ASCII码，需要使用ensure_ascii=False关掉
# s = json.dumps(str1, ensure_ascii=False)
# print(s)
# print(type(s))
#
# 将json内容序列化到文档中

s = {
    "法师": {
        "小法": [
            "约德尔人",
            "自认为很邪恶"
        ],
        "火男": [
            "AOE伤害",
            "消耗强"
        ],
        "安妮": [
            "小熊",
            "幼女魔法师"
        ],
        "光辉": [
            "强控",
            "远程大招"
        ]
    },
    "战士": {
        "赵信": [
            "一点寒芒先到，随后枪出如龙",
            "the Seneschal of Demacia"
        ]
    },
    "射手": {
        "金克斯": [
            "哒哒哒哒哒",
            "究极死神飞弹"
        ]
    }
}

json.dump(s, open('movie.txt', 'w', encoding='utf-8'), ensure_ascii=False)
#
# 读取json文件内容
read = json.load(open('my_json.json', encoding='utf-8'))
print(read)
print(type(read))